app.controller('detailController', ['$scope', 'storageService', '$routeParams',
    function ($scope, storageService, $routeParams) {
        var path = 'races/' + $routeParams['category'] + '/' + $routeParams['detail'];
        $scope.races = storageService.getItem(path);
        $scope.sport = $routeParams['category'];
        
        // Check for updates and update data when done
        storageService.dataUpdated(path).then(function(results){
            if(results.data !== localStorage.getItem(path + '_updated')){
                storageService.updateData(path).then(function(){
                    $scope.races = storageService.getItem(path);
                });
            } 
        });
}]);